# frozen_string_literal: true

def link_reviewer(name)
  "[`@#{name}`](https://gitlab.com/dashboard/merge_requests?assignee_username=#{name}&not[author_username]=#{name})"
end

if gitlab.mr_json['assignees'].none?
  warn <<~TXT
    This merge request does not have any assignee yet. Setting an assignee
    clarifies who needs to take action on the merge request at any given time.
  TXT
end

suggestions = (GITALY_TEAM - [gitlab.mr_author]).sample(2, random: Random.new(gitlab.mr_json['iid']))

case suggestions.size
when 0
when 1
  message "Suggested maintainer: #{link_reviewer(suggestions.first)}"
else
  message "Suggested maintainers: #{link_reviewer(suggestions.first)}, and #{link_reviewer(suggestions.last)}"
end

# vim: ft=ruby
